﻿using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace GameView.Converts
{
    public class IntToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int b)
            {
                var boolRes = b > 0;
                var res = boolRes ? Visibility.Visible : Visibility.Collapsed;
                return res;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Visibility visibility)
            {
                var res = visibility != Visibility.Visible ? 0 : 1;
                return res;
                //return visibility != Visibility.Visible;
            }
            return 0;
        }
    }
}